package com.ruoyi.game.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.game.domain.GameRoomcardTxn;
import com.ruoyi.game.service.IGameRoomcardTxnService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 房卡流水Controller
 * 
 * @author ruoyi
 * @date 2025-04-18
 */
@RestController
@RequestMapping("/game/txn")
public class GameRoomcardTxnController extends BaseController
{
    @Autowired
    private IGameRoomcardTxnService gameRoomcardTxnService;

    /**
     * 查询房卡流水列表
     */
    // @PreAuthorize("@ss.hasPermi('game:txn:list')")
    @GetMapping("/list")
    public TableDataInfo list(GameRoomcardTxn gameRoomcardTxn)
    {
        startPage();
        List<GameRoomcardTxn> list = gameRoomcardTxnService.selectGameRoomcardTxnList(gameRoomcardTxn);
        return getDataTable(list);
    }

    /**
     * 导出房卡流水列表
     */
    // @PreAuthorize("@ss.hasPermi('game:txn:export')")
    @Log(title = "房卡流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GameRoomcardTxn gameRoomcardTxn)
    {
        List<GameRoomcardTxn> list = gameRoomcardTxnService.selectGameRoomcardTxnList(gameRoomcardTxn);
        ExcelUtil<GameRoomcardTxn> util = new ExcelUtil<GameRoomcardTxn>(GameRoomcardTxn.class);
        util.exportExcel(response, list, "房卡流水数据");
    }

    /**
     * 获取房卡流水详细信息
     */
    // @PreAuthorize("@ss.hasPermi('game:txn:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gameRoomcardTxnService.selectGameRoomcardTxnById(id));
    }

    /**
     * 新增房卡流水
     */
    // @PreAuthorize("@ss.hasPermi('game:txn:add')")
    @Log(title = "房卡流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GameRoomcardTxn gameRoomcardTxn)
    {
        return toAjax(gameRoomcardTxnService.insertGameRoomcardTxn(gameRoomcardTxn));
    }

    /**
     * 修改房卡流水
     */
    // @PreAuthorize("@ss.hasPermi('game:txn:edit')")
    @Log(title = "房卡流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GameRoomcardTxn gameRoomcardTxn)
    {
        return toAjax(gameRoomcardTxnService.updateGameRoomcardTxn(gameRoomcardTxn));
    }

    /**
     * 删除房卡流水
     */
    // @PreAuthorize("@ss.hasPermi('game:txn:remove')")
    @Log(title = "房卡流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gameRoomcardTxnService.deleteGameRoomcardTxnByIds(ids));
    }
}
